package scheduler;

import java.sql.*;

public class Reader {
    public static void main(String [] args) throws Exception {
        String studentId;
        String studentLName;
        String studentFName;
        String studentMName;
        String studentCourse;
      //  Student[] stud = new Student [7];
        
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String conStr = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=d:/student.accdb";
    	//edit the database location above: d:/student.accdb
        Connection con = DriverManager.getConnection(conStr);
        System.out.println("Connected");
        
        String selectStatement = "SELECT * FROM student WHERE CLASSCODE='9572'";
        //Edit the statement above
        Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        ResultSet result = stmt.executeQuery(selectStatement);
        
        result.beforeFirst();
        while(result.next()){
            studentId = result.getString(1);
            studentLName = result.getString(2);
            studentFName = result.getString(3);
            studentMName = result.getString(4);
            studentCourse = result.getString(5);
            System.out.printf("%7S %-10s %-12s %-10s %-7s \n", studentId, studentLName, studentFName, studentMName, studentCourse);
            //code creating student with the student class using the values above follows.
        }
       
    }   
}